package ltd.bugs.cute.common.util;

import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class IOUtils {

  private static Logger logger = LoggerFactory.getLogger(IOUtils.class);

  public static void closeQuietly(InputStream stream) {
    if (stream == null) {
      return;
    }
    try {
      stream.close();
    } catch (Exception e) {
      logger.error("close stream error", e);
    }
  }

  public static void closeQuietly(OutputStream stream) {
    if (stream == null) {
      return;
    }
    try {
      stream.close();
    } catch (Exception e) {
      logger.error("close stream error", e);
    }
  }

  public static void closeQuietly(Reader reader) {
    if (reader == null) {
      return;
    }
    try {
      reader.close();
    } catch (Exception e) {
      logger.error("close stream error", e);
    }
  }
}
